package com.alongstudio.account.commons.interceptor;

import org.apache.log4j.Logger;

import com.alongstudio.account.commons.exception.BusinessException;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class ErrorHandlingInterceptor extends AbstractInterceptor {
	private static final long serialVersionUID = -8139868355387689918L;
	static Logger logger = Logger.getLogger(ErrorHandlingInterceptor.class);

	public String intercept(ActionInvocation invocation) throws Exception {
		try {
			return invocation.invoke();
		}
		catch (BusinessException e) {
			logger.error(e.getClassName() + "Business Error Exception" + e.getMessage(), e);
		}
		catch (Exception e) {
			e.printStackTrace();
			logger.error(this.getClass().getName() + "  Application Error Exception", e);
		}
		return Action.ERROR;
	}

}
